package com.example.databean;

import com.example.utils.DateUtils;
import com.example.utils.PostFileUtils;

public class Post {

    static final String url = "\\zzuStuPostBar\\WebContent\\WEB-INF\\upload\\";
    //static final String url = "E:\\AllFileTest";//本地电脑测试文件上传下载的地址
    //static final String url = "\\WEB-INF\\upload";//服务器上传下载的地址路径
    private String authorId;//作者Id
    private String postingsId;//帖子Id
    private String postTime;//发布时间
    private String postTittle;//发布题目
    private String mainWord;//帖子简介
    private String postUrl;//帖子的服务器存储url（相对）
    private int talkNum;//评论数
    private int likeNum;//喜欢数
    private int starNum;//收藏数
    private String postTalkUrl;//帖子评论存储地址（相对）



    public void initPost(String authorId,String postTittle,String mainWord) {
        this.authorId = authorId;//作者Id
        this.postTittle = postTittle;//帖子标题
        this.mainWord = mainWord;//帖子简介
        DateUtils dt = new DateUtils();
        this.postingsId = authorId+dt.getTimeStampToString1();//帖子Id
        this.postTime = dt.getFmtDate();//帖子发布时间
        this.talkNum = 0;
        this.starNum = 0;
        this.likeNum = 0;

    }

    public void initPost(String authorId,String postTittle,String mainWord,String dateimp) {
        this.authorId = authorId;//作者Id
        this.postTittle = postTittle;//帖子标题
        this.mainWord = mainWord;//帖子简介
        DateUtils dt = new DateUtils();
        this.postingsId = authorId+dateimp;//帖子Id
        this.postTime = dt.getFmtDate();//帖子发布时间
        this.talkNum = 0;
        this.starNum = 0;
        this.likeNum = 0;

    }



    public void initFile() {
        //根据authorId+postingsId+"postTittle"
        String urltest = url+this.authorId+this.postingsId+".txt";
        String urltestTalk = url+this.authorId+this.postingsId+"Talk.txt";
        this.postTalkUrl = urltestTalk;
        this.postUrl = urltest;
        PostFileUtils pu = new PostFileUtils();
        pu.initPostFile(this);
    }
    public String getAuthorId() {
        return authorId;
    }
    public void setAuthorId(String authorId) {
        this.authorId = authorId;
    }
    public String getPostingsId() {
        return postingsId;
    }
    public void setPostingsId(String postingsId) {
        this.postingsId = postingsId;
    }
    public String getPostTime() {
        return postTime;
    }
    public void setPostTime(String postTime) {
        this.postTime = postTime;
    }
    public String getPostTittle() {
        return postTittle;
    }
    public void setPostTittle(String postTittle) {
        this.postTittle = postTittle;
    }
    public String getMainWord() {
        return mainWord;
    }
    public void setMainWord(String mainWord) {
        this.mainWord = mainWord;
    }
    public String getPostUrl() {
        return postUrl;
    }
    public void setPostUrl(String postUrl) {
        this.postUrl = postUrl;
    }

    public int getTalkNum() {
        return talkNum;
    }

    public void setTalkNum(int talkNum) {
        this.talkNum = talkNum;
    }

    public int getLikeNum() {
        return likeNum;
    }

    public void setLikeNum(int likeNum) {
        this.likeNum = likeNum;
    }

    public int getStarNum() {
        return starNum;
    }

    public void setStarNum(int starNum) {
        this.starNum = starNum;
    }

    public static String getUrl() {
        return url;
    }

    public String getPostTalkUrl() {
        return postTalkUrl;
    }
    public void setPostTalkUrl(String postTalkUrl) {
        this.postTalkUrl = postTalkUrl;
    }

}

